package com.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.dingdanDao;

/**
 * Servlet implementation class Dd_accountRoot
 */
@WebServlet("/Dd_accountRoot")
public class Dd_accountRoot extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Dd_accountRoot() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");//防止出现中文乱码
		
		// 获取注册信息
		String dd_account =request.getParameter("C");
		
		ArrayList<?> a;
		if(dd_account.equals("")) {
			//查询所有
				a=dingdanDao.getLikeListDd_account();
				request.getSession().setAttribute("C1","查询成功");
			} else {
				//查询单个
				a=dingdanDao.getLikeListDd_account(dd_account);
				request.getSession().setAttribute("C1","查询成功");
			}

		request.getSession().setAttribute("dingdanMessage",a);
		response.sendRedirect("/aaa/dingdanRoot.jsp");
	}

}
